package com.bzchao.github;

import com.alibaba.nacos.api.config.annotation.NacosValue;
import com.bzchao.github.common.DemoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
@RefreshScope
@Component
public class SpringTaskService {

    //TODO 未知原因，动态更新配置将导致定时任务停止
    @Value("${com.test:testName}")
    private String name;
    @Reference(version = "1.0.0")
    private DemoService demoService;

    /**
     * cron表达式，每5秒执行
     */
    @Scheduled(cron = "*/5 * * * * ?")
    public void task2() {
        String mercyblitz = demoService.sayHello(name);
        log.info("提供者传回消息：{}", mercyblitz);
    }
}
